"""
    selenium: 本身是自动化测工具，可以应用在爬虫领域

    pip install selenium -i 镜像源
    pip install webdriver-manager -i 镜像源
"""
from selenium import webdriver
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option('detach', True)
driver = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)
# 打开浏览器
driver.get("https://www.baidu.com/")
driver.maximize_window() # 放到浏览器
# 获取截图
screenshot = driver.get_screenshot_as_png()
# 保存截图到文件
with open('screenshot.png', 'wb') as f:
    f.write(screenshot)
#定位元素
driver.find_element(by=By.ID,value="kw").send_keys("苹果")
driver.find_element(by=By.ID,value="su").click()




